<template>
    <h1>登录页面</h1>

    <table>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="info.Name">
            </td>
        </tr>

        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="info.Pwd">
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="登录" @click="Login">
            </td>
        </tr>

    </table>

</template>

<script setup lang="ts">

import {ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'

const router = useRouter()

const info = ref({
    Name:'',
    Pwd:'',
})

const Login = () => {
    axios({
        method:'get',
        url:'http://localhost:63748/api/User/UserLogin',
        params:{
            Name:info.value.Name,
            Pwd:info.value.Pwd,
        }
    })
    .then(res => {
        if(res.data>0){
            alert('登录成功');
            router.push('/Show');
        }
        else{
            alert('登录失败');
            return;
        }
    })
    .catch(err => {
        console.log(err)
    })
}


</script>
